function ymzxdjl
p1=[1 2 3]';
n1=[1 1 1]';
p2=[1 -2 -3]';
n2=[1 -1 1]';
N=50;
t=linspace(-5,5,N);
P1=repmat(p1,1,N)+repmat(n1,1,N).*repmat(t,3,1);
P2=repmat(p2,1,N)+repmat(n2,1,N).*repmat(t,3,1);
plot3(P1(1,:),P1(2,:),P1(3,:),'-r','Linewidth',2);
hold on
plot3(P2(1,:),P2(2,:),P2(3,:),'-g','Linewidth',2);
plot3(0.5,-1.5,-3.5000,'og');
plot3(-2.5,-1.5,-0.5,'or');
plot3([-2.5 0.5],[-1.5 -1.5],[-0.5 -3.5],'-c','Linewidth',3);
x1=P1(1,:);y1=P1(2,:);
[x1 y1]=meshgrid(x1,y1);
z1=2*y1-x1;
H1=mesh(x1,y1,z1);
set(H1,'facecolor','k','edgecolor','b')
x2=P2(1,:);y2=P2(2,:);
[x2 y2]=meshgrid(x2,y2);
z2=-(2*y2+x2+6);
H2=mesh(x2,y2,z2);
set(H2,'facecolor','y','edgecolor','k')
view(-80,60)
title('异面直线间的距离','Fontsize',20)
hold off
print -djpeg90 异面直线间的距离